package com.lp.biz.system.controller;

import com.lp.biz.system.model.vo.UpdatePassword;
import com.lp.biz.system.service.SysService;
import com.lp.common.annotation.PermissionAnnotation;
import com.lp.common.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

import static com.lp.common.constant.MenuConstant.CONTENT_CLASS;
import static com.lp.common.constant.RoleConstant.CLASS_TEACHER;

/**
 * SysEndpointsController
 * @program: backend
 * @author Ke.Song
 * @since 2024-05-19 00:37:24
 */
@RestController
@RequestMapping("/sys")
public class SysController {

    @Autowired
    private SysService sysService;

    /**
     * 获取所有菜单
     * @return 查询结果
     */
    @GetMapping("/menu")
    public CommonResult getAllMenu() {
        return sysService.getAllMenu();
    }

    /**
     * 获取STS token
     * @return token
     */
    @GetMapping("/sts")
    public CommonResult getStsToken() {
        return sysService.getStsToken();
    }


    /**
     * 登出
     * @param request 请求
     * @return 处理结果
     */
    @PostMapping("/logout")
    public CommonResult logout(HttpServletRequest request) {
        sysService.logout(request);
        return CommonResult.success();
    }

    /**
     * 修改密码
     * @param password 新密码
     * @return 处理结果
     */
    @PutMapping("/password")
    public CommonResult updatePassword(@RequestBody @Validated UpdatePassword password) {
        sysService.updatePassword(password);
        return CommonResult.success();
    }

    /**
     * 获取小铃铛消息
     * @return 查询结果
     */
    @GetMapping("/notice")
    public CommonResult getSysNotice() {
        return sysService.getSysNotice();
    }
}
